package cn.itcast.bos.mq;

import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.springframework.stereotype.Service;

import cn.itcast.bos.utils.SmsUtils;
@SuppressWarnings("unused")
@Service("smsConsumer")
public class SmsConsumer implements  MessageListener{

	@Override
	public void onMessage(Message message) {
		try {
			MapMessage mapMessage = (MapMessage) message;
			String telephone = mapMessage.getString("telephone");
			String sms = mapMessage.getString("msg");
			//String result = SmsUtils.sendSmsByHTTP(telephone, sms);
			String result = "000/xxxx";
			if (result.startsWith("000")) {
				// 发送成功
				
			} else {
				// 发送失败
				throw new RuntimeException("短信发送失败, 信息码：" + result);
			}
		} catch (Exception e) {
		}
	}

}
